package mta.io;

import mta.io.csv.writer.CsvTranslationsWriter;
import mta.localization.LocalizationPackage;

/**
 * Created by Dmitry Nikolaev.
 * User: dima
 * Date: 19.01.2009
 * Time: 19:01:15
 */
public class LocalizationPackageWriter {

    private CsvTranslationsWriter writer;
    private boolean clear;

    public LocalizationPackageWriter(CsvTranslationsWriter writer, boolean clear) {
        this.writer = writer;
        this.clear = clear;
    }

    public void updatePackage(LocalizationPackage localization) {
        if (clear) {
            writer.clear();
        }
        for (String moduleName : localization.getAllModules()) {
            writer.writeFile(moduleName, localization.getModulePhrases(moduleName));
        }
    }

}
